package com.sccc.entity;

import java.util.Map;

import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;

public class AdminConverter extends DefaultTypeConverter {
	@Override
	public Object convertValue(Map<String, Object> context, Object value, Class toType) {
	
		if(toType==Admin.class){
			String[] params = (String[]) value;
			String adminStr = params[0];
			String[] admininfo = adminStr.split(",");
			String name = admininfo[0];
			String pass = admininfo[1];
			Admin user = new Admin();
			user.setUsername(name);
			user.setPasswd(pass);
			return user;
		}else if(toType==String.class){
			
			Admin user = (Admin) value;
			return "用户名和密码为：["+user.getUsername()+","+user.getPasswd()+"]";
			
		}else{
			return null;
		}
	}

}
